home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Personal Computer World 2009 February
/
PCWFEB09.iso
/
Software
/
Resources
/
Browsers, Managers & Extensions
/
Firefox Backup Extension 6.0.3
/
chrome
/
febe.jar
/
content
/
febeVerifyext.js
< prev
next >
Wrap
Text File
|
2008-08-06
|
5KB
|
145 lines
// author: Chuck Baker
// contact: febe@customsoftwareconsult.com
// Version 6.0
febeSetMsgs();
function febeVerifyExtension(){
febex = false;
febeVerifyExtensions();
if(febex) febeVerifyExtensions(); // Run again to fix
return true;
}//function febeVerifyExtension(){
function febeVerifyExtensions(){
window.document.title = febeMsg[237];
// Create pointer to profile directory
febeProfDir = Cc["@mozilla.org/file/directory_service;1"].getService(Ci.nsIProperties).get("ProfD", Ci.nsIFile);
var extDir = febeProfDir.clone();
extDir.append("extensions");
var errCnt = 0;
var extCnt = 0;
var entries = extDir.directoryEntries;
while(entries.hasMoreElements()){
var entry = entries.getNext();
entry.QueryInterface(Ci.nsILocalFile);
if(!entry.isDirectory()){
if(febex){
if(febeDeleteInvalidExt(entry.path)){
var tmp = "<p><b>"+febeMsg[226]+"</b> "+febeMsg[220].replace("%PATH%",entry.path)+" <b>"+febeMsg[227]+"</b><br></p>";
febeprt(tmp);
continue;
}//if
}//if
var tmp = "<p>***";
tmp += "<b>"+febeMsg[226]+"</b><br>";
tmp += "<b>"+febeMsg[220].replace("%PATH%",entry.path)+"</b><br>";
tmp += "***</p>";
febeprt(tmp,"red",15); // Not a directory
errCnt++;
continue;
}//if
var GUID = extDir.clone();
GUID.append(entry.leafName);
var entries2 = GUID.directoryEntries;
if(!entries2.hasMoreElements()){
if(!entry.isDirectory()){
if(febex){
if(febeDeleteInvalidExt(entry.path)){
var tmp = "<p><b>"+febeMsg[226]+"</b> "+febeMsg[221].replace("%GUID%",GUID.path)+" <b>"+febeMsg[227]+"</b><br></p>";
febeprt(tmp);
continue;
}//if
}//if
var tmp = "<p>***";
tmp += "<b>"+febeMsg[226]+"</b><br>";
tmp += "<b>"+febeMsg[221].replace("%GUID%",GUID.path)+"</b><br>";
tmp += "***</p>";
febeprt(tmp,"red",15); // Directory is empty
errCnt++;
continue;
}//if
}//if
GUID.append("install.rdf");
if(!GUID.exists()){
if(febex){
if(febeDeleteInvalidExt(entry.path)){
var tmp = "<p><b>"+febeMsg[226]+"</b> "+febeMsg[222].replace("%ITEM%",GUID.path)+" <b>"+febeMsg[227]+"</b><br></p>";
febeprt(tmp);
continue;
}//if
}//if
var tmp = "<p>***";
tmp += "<b>"+febeMsg[226]+"</b><br>";
tmp += febeMsg[222].replace("%ITEM%",GUID.path)+"<br>";
tmp += "***</p>";
febeprt(tmp,"red",15); // No install.rdf
errCnt++;
continue;
}//if
var thisExt = new febeExtInfo(GUID.parent.leafName);
//alert(GUID.parent.leafName)
if(!thisExt) continue;
var extName = thisExt.name;
var extVer = febeStripSpaces(thisExt.version);
var extIsDisabled = thisExt.isDisabled;
var extIcon = thisExt.iconURL;
if(extIsDisabled){extIcon = "chrome://febe/skin/disabled.png";}
var extHome = thisExt.homepageURL;
var eType = thisExt.type; // 2=Extension, 4=Theme
if(eType != 2 && eType != 4){continue;} // Not an extension or theme ... what is it?
var tmp = "<img src='"+extIcon+"' ";
tmp += "style='border: 0px solid ; width: 16px; height: 16px;'/> ";
tmp += thisExt.guid+" <b>"+extName+"</b>";
if(extIsDisabled) tmp += " <i>(disabled)</i>";
tmp += " - OK";
if(eType == 2){
febeprt(tmp,"blue"); // Extension
}//if
if(eType == 4){
febeprt(tmp,"green"); // Theme
}//if
extCnt++;
}//while
if(errCnt == 0){
var tmp = febeMsg[223].replace("%CNT%",extCnt); // All OK
febeprt(tmp,"purple");
febeAlert(tmp);
}else{
var tmp = "<style>color: red; font-weight: bold; font-size: 20px;</style>";
tmp += febeMsg[224] + "\n";
tmp += "<style>color: purple; font-weight: bold; font-size: 15px;</style>"+febeMsg[225];
febex = febeConfirm(tmp);
//if(!OK){return false;}
}//if
var box = document.getElementById("messages");
box.contentDocument.close();
return true;
}//febeVerifyExtensions()
function febeDeleteInvalidExt(path){
var aFile = Cc["@mozilla.org/file/local;1"].createInstance(Ci.nsILocalFile);
if (!aFile) return false;
aFile.initWithPath(path);
try{
aFile.remove(true);
}catch(e){
febeAlert(e.toString())
return false;
}//try/catch
return true;
}//febeDeleteInvalidExt()
function febeprt(txt,color,size){
// Display content in log window
if(!color) color="black";
if(!size) size = 12;
var box = document.getElementById("messages");
txt = "<span style='font-family: Courier New,Courier,monospace; font-size: "+size+"px; color: "+color+";'>"+txt+"<br></span>"
box.contentDocument.write(txt);
var scrollBox = box.contentWindow.document.body;
scrollBox.scrollTop = scrollBox.scrollHeight - scrollBox.clientHeight
return true;
}//febeprt()